from tkinter import font
import PySimpleGUI as sg
import pyautogui

sg.theme('DarkBrown1')

layout = [  [sg.Text('当前位置', size=(50, 2), justification='center')],
            [sg.Push(),sg.Text(size=(15, 2), font=('Helvetica', 20), justification='center', key='-OUTPUT-'),sg.Push()],
            [sg.Push(),sg.Quit()]]

window = sg.Window('获取鼠标坐标', layout)

timer_running = True

while True:
    x,y = pyautogui.position()
    event, values = window.read(timeout=10)
    if event in (sg.WIN_CLOSED, 'Quit'):
        break
    if timer_running:
        window['-OUTPUT-'].update('X:%s , Y:%s'%(x,y))
window.close()